CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(NodesTest CXX)

ENABLE_TESTING(TRUE)
FIND_PACKAGE(GTest REQUIRED)

# find Gmock library 
# throw error if library wasn't found
FIND_LIBRARY(GMOCK_LIBRARIES gmock
    HINTS
        $ENV{GMOCK_ROOT}
        ${GMOCK_ROOT}
		$ENV{GMOCK_ROOT}/make
        ${GMOCK_ROOT}/make
)
if(NOT DEFINED GMOCK_LIBRARIES)
	MESSAGE(SEND_ERROR "GMOCK library was not found")
endif()

# find Gmock include files
# throw error if include files weren't found
find_path(GMOCK_INCLUDE_DIR gmock/gmock.h
    HINTS
        $ENV{GMOCK_ROOT}/include
        ${GMOCK_ROOT}/include
)
if(NOT DEFINED GMOCK_INCLUDE_DIR)
	MESSAGE(SEND_ERROR "Include for GMOCK library was not found")
endif()	

IF(NOT CMAKE_BUILD_TYPE)
    SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: Debug Release" FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${GMOCK_INCLUDE_DIR})

SET(TEST_SOURCES
    Test/main.cpp 
    Test/IntegrationTest.cpp
    Test/ExplicitPrinterTest.cpp
    Test/PrettyPrinterTest.cpp
    Test/PostfixPrinterTest.cpp
    Test/NodeStackTest.cpp
    Test/PostfixParserTest.cpp
    Test/BinaryNodeTest.cpp
    Test/CompareNodesTest.cpp
    Test/ClassicNNFProcessorTest.cpp
    Test/InplaceNNFProcessorTest.cpp
    Test/InvestigateBinaryNodeTest.cpp
    Test/InvestigateInplaceNNFProcessorTest.cpp
)
ADD_EXECUTABLE(NodesTest ${TEST_SOURCES})

TARGET_LINK_LIBRARIES(NodesTest 
	${GTEST_BOTH_LIBRARIES}
	${GMOCK_LIBRARIES}	
)

SET(CTEST_OUTPUT_ON_FAILURE TRUE)
GTEST_ADD_TESTS(NodesTest "" ${TEST_SOURCES}) 
